<template>
  <div class="content">
    <div class="w_img">
      <img :src="datamsg.headimgurl" alt="">
    </div>
    <div class="w_title">{{datamsg.username}}</div>
    <div class="w_time">{{datamsg.title}}</div>
    <div class="writebox quer" v-show="datamsg.state === 0" @click="surebtn">确定绑定</div>
    <div class="writebox qux" v-show="datamsg.state === 0" @click="nobin">暂不绑定</div>
    <div class="writebox qux" v-show="datamsg.state === 1">已绑定</div>
  </div>
</template>

<script>
import { bindInfo, confirmBind } from '@/api/public'
export default {
  name: 'Write',
  data () {
    return {
      aid: '',
      noceStr: '',
      singstr: '',
      datamsg: {}
    }
  },
  created () {
    if (this.$route.query.aid) {
      this.aid = this.$route.query.aid
      this.noceStr = this.$route.query.noceStr
      this.singstr = this.$route.query.singstr
    }
    this.getdata()
  },
  methods: {
    getdata () {
      const { aid, noceStr, singstr } = this
      bindInfo(aid, noceStr, singstr).then(res => {
        this.datamsg = res
      }).finally(() => {
      })
    },
    surebtn () {
      const { aid, noceStr, singstr } = this
      confirmBind(aid, noceStr, singstr).then(res => {
        this.$toast.success('绑定成功')
      }).finally(() => {
      })
    },
    nobin () {
      this.$router.go(-1)
    }
  }
}
</script>

<style scoped lang="less">
.content{
  width: 100%;
  height: 100%;
  padding: 19% 0;
  background-color: white;
  box-sizing: border-box;
  text-align: center;
  .w_img{
    margin: 0 auto;
    width: 200px;
    height: 200px;
    background-color: #ffffff;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: -1px 5px 15px 1px rgba(232, 232, 232, 0.5);
    img{
        width: 100%;
        height: 100%;
        background-size: cover;
    }
  }
  .w_title{
    margin-top: 20px;
    text-align: center;
    font-size: 30px;
  }
  .w_time{
    margin: 100px 0 80px;
    font-size: 28px;
    color: #666666;
  }
  .writebox{
    margin: 20px auto 0;
    width: 400px;
    height: 80px;
    border-radius: 40px;
    line-height: 80px;
    line-height: 80px;
    color: #ffffff;
    font-size: 28px;
    text-align: center;
  }
  .qux{
    background-color: #d7d7d7;
  }
  .quer{
    background: #fca64a;
  }
}
</style>
